package com.crack.nga2.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Scroller;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.crack.nga2.R;
import com.crack.nga2.utils.GlobalConst;


/**
 * 基类Activity
 * Created by Administrator on 2016/1/23.
 */
public class BaseActivity extends AppCompatActivity {
    protected final static int THEME_SMALL_FONT = 0;
    protected final static int THEME_NORMAL_FONT = 1;
    protected final static int THEME_LARGET_FONT = 2;
    protected final static int THEME_MORE_LARGET_FONT = 3;
    protected static int CURRENT_THEME = THEME_NORMAL_FONT;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @SuppressWarnings("unchecked")
    protected <T> T $(@IdRes int resId) {
        return (T) findViewById(resId);
    }

    @SuppressWarnings("unchecked")
    protected <T> T $(View view, @IdRes int resId) {
        return (T) view.findViewById(resId);
    }

    protected void setCurrentTheme(int themeIndex) {
        switch (themeIndex) {
            case THEME_SMALL_FONT:
                setTheme(R.style.small);
                break;
            case THEME_NORMAL_FONT:
                setTheme(R.style.normal);
                break;
            case THEME_LARGET_FONT:
                setTheme(R.style.larget);
                break;
            case THEME_MORE_LARGET_FONT:
                setTheme(R.style.more_larget);
                break;
        }
    }

    @Override
    public void finish() {
        super.finish();
        NgaApplication.cancelAllVolleyRequest();

    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
        super.startActivityForResult(intent, requestCode, options);
        overridePendingTransition(R.anim.base_slide_right_in, R.anim.base_slide_right_out);
    }


    protected void finishForAnimation() {
        finish();
        overridePendingTransition(R.anim.base_slide_left_in, R.anim.base_slide_left_out);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(R.anim.base_slide_left_in, R.anim.base_slide_left_out);
    }



}
